package com.tucc.hello.other;

/**
 * @author tucc
 * @description todo
 * @package com.tucc.hello
 * @date 2021/5/20
 **/
public class Other {


    public static void main(String[] args) {
        int[] arr = {1,2,10,3,8,4,5,6};
        sortOddEven(arr);
        printArray(arr);
    }

    public static void printArray(int[] arr){
        for(int num : arr){
            System.out.println(num);
        }
    }

    public static void sortOddEven(int[] arr){
        int l = 0;
        int r = arr.length - 1;
        while(l < r){
            while(arr[l] % 2 == 1){
                l ++;
            }
            while(arr[r] % 2 == 0){
                r --;
            }
            if(l < r){
                int temp = arr[l];
                arr[l] = arr[r];
                arr[r] = temp;
            }
        }
    }
}
